<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS 函数</title>
</head>

<body>
    <script>
        function hello() {
            console.log("Hello, 函数!");
        }
        hello();

        function hello_with_return() {
            return 'hello, 带返回值的函数';
        }
        let a = hello_with_return();
        console.log(a);
        console.log(hello_with_return());

        function hello_with_params(name) {
            console.log('hello' + name);
        }
        hello_with_params('丹恒');

        // 作用域
        let global_let = '全局变量';
        function local_let_function() {
            let local_let = '局部变量';
            console.log('函数内打印全局变量' + global_let);
            console.log('函数内打印局部变量' + local_let);
        }
        local_let_function();
        console.log('函数内打印全局变量' + global_let);
        console.log('函数内打印局部变量' + local_let);
    </script>
</body>

</html>